This invention generally relates to improvements in object oriented applications. More particularly, it relates to deriving a metaclass for a new class defined by subclassing in an object oriented system.
Among developers of workstation software, object-oriented programming (or OOP) is increasingly recognized as an important new programming technology. It offers expanded opportunities for software reuse and extensibility, with improved programmer productivity when compared to conventional software development paradigms. Even so, object-oriented technology has not effectively penetrated major commercial software products to date. In particular, operating-systems have hesitated to embrace the new technology.
As with many new programming technologies, the early expressions of OOP concepts focused on the creation of new languages and toolkits, each designed to exploit some particular aspect. So-called pure object-oriented languages, such as Smalltalk, presume a complete run-time environment (sometimes known as a virtual machine) because their semantics represent a major departure from traditional procedurally oriented system architectures. Hybrid languages such as C++, on the other hand, require less run-time support but sometimes result in tight bindings between programs that provide objects and the client programs that use them. Tight binding between object-providing programs and their clients often require client programs to be recompiled whenever simple changes are made in the providing programs. Examples of such systems are found in U.S. Pat. Nos. 885,717; 4,953,080 and 4,989,132.
Because different languages and object-oriented toolkits emphasize different aspects of OOP, the utility of the resulting software is frequently limited in scope. A C++ programmer, for example, cannot easily use objects developed in Smalltalk, nor can a Smalltalk programmer make effective use of C++ objects. Objects and classes implemented in one language simply cannot be readily used from another. Unfortunately, when this occurs, one of the major benefits of OOP, the increased reuse of code, is severely curtailed. Object-oriented language and toolkit boundaries become, in effect, barriers to interoperability.
As taught in commonly assigned, copending application, Ser. No. 805,668, entitled xe2x80x9cThe System Object Model Object Interface Definition Languagexe2x80x9d to M. H. Conner et al., a new language neutral object oriented programming mechanism called SOM (for System Object Model) alleviates many of the problems of the prior art. In SOM, a programmer may define a new class of objects by a process called subclassing by which characteristics from a parent class and inherited and/or overridden. The class of an object itself is an object, a xe2x80x9cclass objectxe2x80x9d. Further, since in SOM, every object is an instance of a class, each class object must also be an instance of some class. The classes of class objects are called xe2x80x9cmetaclassesxe2x80x9d. To maximize the power of SOM, programmers must be able to specify the metaclass for a particular class object. Yet, if a programmer is allowed to specify the metaclass, it is possible that this metaclass will not fully support class instances which are developed by subclassing from a parent class, particularly if the new class is derived by subclassing multiple parent classes.
The earlier application provided no solution to this problem. In other object oriented languages which provide class objects, such as Smalltalk, the programmer is restricted from explicitly specifying metaclasses, thus limiting the potential benefits of defining a class object. Further, in Smalltalk a program may not specify more than one parent class from which to derive a new class.
The present application presents a solution to the above problem.
Accordingly, it is an objective of the present invention to provide a language neutral object oriented programming system in which (1) every object is an instance of some specific class, (2) classes are objects derived by subclassing, and (3) the class of any class derived by subclassing is automatically derived by the system.
It is another objective of the present invention to automatically derive a metaclass for a new class defined by subclassing multiple parent classes.
It is another objective of the present invention to allow the specification of a metaclass for a new class derived by subclassing.
These and other objectives of the present invention are accomplished in a preferred embodiment by the operation of a set of instructions in the memory of a processor. A file containing a language neutral Object Interface Definition Language (OIDL) definition for a new class of objects to be derived by subclassing is recovered from a disk or other storage medium and input to a compiler resident in the memory of a computer. The compiler is a tool that converts the OIDL definition file into an intermediate form. The intermediate form is input to an emitter. An emitter is a collection of utility instructions used to convert the intermediate form of the file into bindings which instruct the processor how to create the new class of objects expressed for a particular target programming language. The bindings are input to a compiler for the particular target language to generate object modules. Finally, object modules are link edited to create a loadable module. The loadable module is available to any application program requiring its unique object functionality.
When executed, the bindings for a new class defined by subclassing invoke the automatic derivation of another class, called a metaclass, of which the new class will be an instance. The derived metaclass is then used by the bindings to construct and initialize the new class, inheriting aspects from each of the new class""s parent classes, overriding inherited aspects when this is appropriate and adding any new aspects that are special to the new class. The metaclass used to construct and initialize the new class is automatically derived by subclassing from an optional metaclass that may be specified by the programmer and from the metaclasses that were used to construct and initialize the new class""s parent classes.